home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIContentPolicy.idl < prev    next >
Text File  |  2006-05-08  |  9KB  |  226 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* vim: set ft=cpp tw=78 sw=2 et ts=8 : */
  3. /* ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is Mozilla code.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Zero-Knowledge Systems, Inc.
  20.  * Portions created by the Initial Developer are Copyright (C) 2000
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Timothy Watt <riceman+bmo@mail.rit.edu>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  28.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #include "nsISupports.idl"
  41.  
  42. interface nsIURI;
  43. interface nsIDOMNode;
  44.  
  45. /**
  46.  * Interface for content policy mechanism.  Implementations of this
  47.  * interface can be used to control loading of various types of out-of-line
  48.  * content, or processing of certain types of in-line content.
  49.  *
  50.  * WARNING: do not block the caller from shouldLoad or shouldProcess (e.g.,
  51.  * by launching a dialog to prompt the user for something).
  52.  */
  53.  
  54. [scriptable,uuid(3bb1a3c8-3073-41e0-9a26-a7671955fb65)]
  55. interface nsIContentPolicy : nsISupports
  56. {
  57.   const unsigned long TYPE_OTHER       = 1;
  58.  
  59.   /**
  60.    * Indicates an executable script (such as JavaScript).
  61.    */
  62.   const unsigned long TYPE_SCRIPT      = 2;
  63.  
  64.   /**
  65.    * Indicates an image (e.g., IMG elements).
  66.    */
  67.   const unsigned long TYPE_IMAGE       = 3;
  68.  
  69.   /**
  70.    * Indicates a stylesheet (e.g., STYLE elements).
  71.    */
  72.   const unsigned long TYPE_STYLESHEET  = 4;
  73.  
  74.   /**
  75.    * Indicates a generic object (plugin-handled content typically falls under
  76.    * this category).
  77.    */
  78.   const unsigned long TYPE_OBJECT      = 5;
  79.  
  80.   /**
  81.    * Indicates a document at the top-level (i.e., in a browser).
  82.    */
  83.   const unsigned long TYPE_DOCUMENT    = 6;
  84.  
  85.   /**
  86.    * Indicates a document contained within another document (e.g., IFRAMEs,
  87.    * FRAMES, and OBJECTs).
  88.    */
  89.   const unsigned long TYPE_SUBDOCUMENT = 7;
  90.  
  91.   /**
  92.    * Indicates a timed refresh.
  93.    *
  94.    * shouldLoad will never get this, because it does not represent content
  95.    * to be loaded (the actual load triggered by the refresh will go through
  96.    * shouldLoad as expected).
  97.    *
  98.    * shouldProcess will get this for, e.g., META Refresh elements and HTTP
  99.    * Refresh headers.
  100.    */
  101.   const unsigned long TYPE_REFRESH     = 8;
  102.  
  103.  
  104.   //////////////////////////////////////////////////////////////////////
  105.  
  106.   /**
  107.    * Returned from shouldLoad or shouldProcess if the load or process request
  108.    * is rejected based on details of the request.
  109.    */
  110.   const short REJECT_REQUEST = -1;
  111.  
  112.   /**
  113.    * Returned from shouldLoad or shouldProcess if the load/process is rejected
  114.    * based solely on its type (of the above flags).
  115.    *
  116.    * NOTE that it is not meant to stop future requests for this type--only the
  117.    * current request.
  118.    */
  119.   const short REJECT_TYPE = -2;
  120.  
  121.   /**
  122.    * Returned from shouldLoad or shouldProcess if the load/process is rejected
  123.    * based on the server it is hosted on or requested from (aContentLocation or
  124.    * aRequestOrigin), e.g., if you block an IMAGE because it is served from
  125.    * goatse.cx (even if you don't necessarily block other types from that
  126.    * server/domain).
  127.    * 
  128.    * NOTE that it is not meant to stop future requests for this server--only the
  129.    * current request.
  130.    */
  131.   const short REJECT_SERVER = -3;
  132.  
  133.   /**
  134.    * Returned from shouldLoad or shouldProcess if the load/process is rejected
  135.    * based on some other criteria. Mozilla callers will handle this like
  136.    * REJECT_REQUEST; third-party implementors may, for example, use this to
  137.    * direct their own callers to consult the extra parameter for additional
  138.    * details.
  139.    */
  140.   const short REJECT_OTHER = -4;
  141.  
  142.   /**
  143.    * Returned from shouldLoad or shouldProcess if the load or process request
  144.    * is not rejected.
  145.    */
  146.   const short ACCEPT = 1;
  147.  
  148.   //////////////////////////////////////////////////////////////////////
  149.  
  150.   /**
  151.    * Should the resource at this location be loaded?
  152.    * ShouldLoad will be called before loading the resource at aContentLocation
  153.    * to determine whether to start the load at all.
  154.    *
  155.    * @param aContentType      the type of content being tested. This will be one
  156.    *                          one of the TYPE_* constants.
  157.    *
  158.    * @param aContentLocation  the location of the content being checked; must
  159.    *                          not be null
  160.    *
  161.    * @param aRequestOrigin    OPTIONAL. the location of the resource that
  162.    *                          initiated this load request; can be null if
  163.    *                          inapplicable
  164.    *
  165.    * @param aContext          OPTIONAL. the nsIDOMNode or nsIDOMWindow that
  166.    *                          initiated the request, or something that can QI
  167.    *                          to one of those; can be null if inapplicable.
  168.    *
  169.    * @param aMimeTypeGuess    OPTIONAL. a guess for the requested content's
  170.    *                          MIME type, based on information available to
  171.    *                          the request initiator (e.g., an OBJECT's type
  172.    *                          attribute); does not reliably reflect the
  173.    *                          actual MIME type of the requested content
  174.    *
  175.    * @param aExtra            an OPTIONAL argument, pass-through for non-Gecko
  176.    *                          callers to pass extra data to callees.
  177.    *
  178.    * @return ACCEPT or REJECT_*
  179.    */
  180.   short shouldLoad(in unsigned long aContentType,
  181.                    in nsIURI        aContentLocation,
  182.                    in nsIURI        aRequestOrigin,
  183.                    in nsISupports   aContext,
  184.                    in ACString      aMimeTypeGuess,
  185.                    in nsISupports   aExtra);
  186.  
  187.   /**
  188.    * Should the resource be processed?
  189.    * ShouldProcess will be called once all the information passed to it has
  190.    * been determined about the resource, typically after part of the resource
  191.    * has been loaded.
  192.    *
  193.    * @param aContentType      the type of content being tested. This will be one
  194.    *                          one of the TYPE_* constants.
  195.    *
  196.    * @param aContentLocation  OPTIONAL; the location of the resource being
  197.    *                          requested: MAY be, e.g., a post-redirection URI
  198.    *                          for the resource.
  199.    *
  200.    * @param aRequestOrigin    OPTIONAL. the location of the resource that
  201.    *                          initiated this load request; can be null if
  202.    *                          inapplicable
  203.    *
  204.    * @param aContext          OPTIONAL. the nsIDOMNode or nsIDOMWindow that
  205.    *                          initiated the request, or something that can QI
  206.    *                          to one of those; can be null if inapplicable.
  207.    *
  208.    * @param aMimeType         the MIME type of the requested resource (e.g.,
  209.    *                          image/png), as reported by the networking library,
  210.    *                          if available (may be empty if inappropriate for
  211.    *                          the type, e.g., TYPE_REFRESH).
  212.    *
  213.    * @param aExtra            an OPTIONAL argument, pass-through for non-Gecko
  214.    *                          callers to pass extra data to callees.
  215.    *
  216.    * @return ACCEPT or REJECT_*
  217.    */
  218.   short shouldProcess(in unsigned long aContentType,
  219.                       in nsIURI        aContentLocation,
  220.                       in nsIURI        aRequestOrigin,
  221.                       in nsISupports   aContext,
  222.                       in ACString      aMimeType,
  223.                       in nsISupports   aExtra);
  224.  
  225. };
  226.